<script type="text/javascript">
$(function() {
	var pg = App.office.groupEdit.ui, pp = pg.params || {};
	
	var frm = {
		name : pg.seek('name'),
		memo : pg.seek('memo')
	}

	function getValues(){
		return {
			id: pp.id,
			name : frm.name.val(),
			memo : frm.memo.val()
		}
	}
	
	function setValues(o){
		frm.name.val(o.name);
		frm.memo.val(o.memo);
	}
	
	function valid(p){
		pg.find('.msg').html('');
		if(!p.name){
			frm.name.next().html('名称不能为空');
			return false;
		}
		return true;
	}
	
	pg.seek('ok').click(function(){
		var pms = getValues();
		if (!valid(pms)) {
			return false;
		}
		$.post(App.office.ctx + '/group/save.do', pms, function(data){
			var ro = mac.eval(data);
			if (ro.success) {
				pg.callback();
				pg.close();
				return;
			}
			mac.alert(ro.data, ro.params);
		});
		return false;
	});
	
	pg.seek('cancel').click(function(){
		pg.close();
	});
	setValues(pp);
});
</script>
<div class="form">
	<div class="item">
		<div class="label">名称:</div>
		<input type="text" name="name" style="width: 290px"
			required="required" maxlength="64" class="empty" />
		<div class="clear"></div>
	</div>
	<div class="item">
		<div class="label">备注:</div>
		<textarea name="memo" style="width: 290px" maxlength="255"
			class="empty"></textarea>
		<div class="clear"></div>
	</div>
	<div class="msg"></div>
	<div class="bottom">
		<button name="ok">保存</button>
		<button name="cancel">取消</button>
	</div>
</div>